/*    */ package com.hp.bon.sgw.service;
/*    */ 
/*    */ import com.hp.bon.omc.OMCAlarmInterface;
/*    */ import com.hp.bon.sgw.start.SpringContext;
/*    */ import java.util.HashSet;
/*    */ import java.util.Set;
/*    */ import org.jboss.resteasy.client.ProxyFactory;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class OmcRestService
/*    */   implements ConfigListener
/*    */ {
/* 17 */   private static final Logger logger = LoggerFactory.getLogger(OmcRestService.class);
/*    */   private String restIp;
/*    */   private String restPort;
/*    */   private static OmcRestService instance;
/* 34 */   protected final Set<String> monitorConfKeys = new HashSet();
/*    */ 
/*    */   public static OmcRestService getInstance()
/*    */   {
/* 25 */     if (instance == null) {
/* 26 */       instance = new OmcRestService();
/* 27 */       instance.init();
/*    */ 
/* 29 */       SpringContext.getInstance().getConfigService().addConfigListener(instance);
/*    */     }
/* 31 */     return instance;
/*    */   }
/*    */ 
/*    */   private OmcRestService()
/*    */   {
/* 37 */     this.monitorConfKeys.add("omc.rest.ip");
/* 38 */     this.monitorConfKeys.add("omc.rest.port");
/*    */   }
/*    */ 
/*    */   private void loadOmcRestConf()
/*    */   {
/* 43 */     this.restIp = SpringContext.getInstance().getConfigService().getValue("omc.rest.ip", null);
/* 44 */     this.restPort = SpringContext.getInstance().getConfigService().getValue("omc.rest.port", null);
/*    */ 
/* 46 */     logger.info("OMC restIp :" + this.restIp + " restPort " + this.restPort);
/*    */   }
/*    */ 
/*    */   private void init()
/*    */   {
/* 51 */     loadOmcRestConf();
/*    */   }
/*    */ 
/*    */   public OMCAlarmInterface getOMCAlarmInterface()
/*    */   {
/* 56 */     OMCAlarmInterface omc = null;
/*    */ 
/* 58 */     if ((this.restIp != null) && (this.restPort != null))
/*    */     {
/* 60 */       String url = "http://" + this.restIp + ":" + this.restPort + "/man";
/* 61 */       omc = (OMCAlarmInterface)ProxyFactory.create(OMCAlarmInterface.class, url);
/*    */     }
/* 63 */     return omc;
/*    */   }
/*    */ 
/*    */   public Set<String> monitorConfKeys()
/*    */   {
/* 69 */     return this.monitorConfKeys;
/*    */   }
/*    */ 
/*    */   public void onConfigUpdated(String updatedKey)
/*    */   {
/* 74 */     loadOmcRestConf();
/*    */   }
/*    */ }

/* Location:           C:\Users\think\Desktop\sgw_2.1.jar
 * Qualified Name:     com.hp.bon.sgw.service.OmcRestService
 * JD-Core Version:    0.6.1
 */